1
1
mirror of https://github.com/ariya/phantomjs.git synced 2024-09-11 12:55:33 +03:00
phantomjs/test/basics/module.js
Zack Weinberg 5a266e48dc Convert non-webpage tests to the new format.
This covers fs-spec-*.js, require/require_spec.js, module_spec.js,
webkit-spec.js, and webserver-spec.js.  Also, incorporate
set/690-ttf-crash/ as a regression test (it wasn't being run
automatically).

Part of issue #13478 (test suite overhaul).
2015-10-20 17:10:47 -04:00

28 lines
926 B
JavaScript

// Test the properties of the 'module' object.
// Assumes the 'dummy_exposed' module is to be found in a directory
// named 'node_modules'.
// Module load might fail, so do it in a setup function.
var module;
setup(function () {
module = require("dummy_exposed");
});
test(function() {
assert_regexp_match(module.filename, /\/node_modules\/dummy_exposed\.js$/);
}, "module.filename is the absolute pathname of the module .js file");
test(function() {
assert_regexp_match(module.dirname, /\/node_modules$/);
}, "module.dirname is the absolute pathname of the directory containing "+
"the module");
test(function() {
assert_equals(module.id, module.filename);
}, "module.id equals module.filename");
test(function() {
var dummy_file = module.require('./dummy_file');
assert_equals(dummy_file, 'spec/node_modules/dummy_file');
}, "module.require is callable and resolves relative to the module");