Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sudo: false
language: node_js
node_js:
- "4"
- "6"
- "8"
- "10"
Expand All @@ -10,4 +9,4 @@ env:
- BUILD_TIMEOUT=10000
install: npm install --ignore-scripts
before_install:
- if [[ $TRAVIS_NODE_VERSION -lt 7 ]]; then npm install --global npm@4; fi
- if [[ $TRAVIS_NODE_VERSION -lt 8 ]]; then npm install --global npm@5; fi
27 changes: 27 additions & 0 deletions test/addExtension.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const assert = require( 'assert' );
const addExtension = require( '..' ).addExtension;

describe( 'addExtension', function () {
it( 'adds .js to an ID without an extension', function () {
assert.equal( addExtension( 'foo' ), 'foo.js' );
});

it( 'ignores file with existing extension', function () {
assert.equal( addExtension( 'foo.js' ), 'foo.js' );
assert.equal( addExtension( 'foo.json' ), 'foo.json' );
});

it( 'ignores file with trailing dot', function () {
assert.equal( addExtension( 'foo.' ), 'foo.' );
});

it( 'ignores leading .', function () {
assert.equal( addExtension( './foo' ), './foo.js' );
assert.equal( addExtension( './foo.js' ), './foo.js' );
});

it( 'adds a custom extension', function () {
assert.equal( addExtension( 'foo', '.wut' ), 'foo.wut' );
assert.equal( addExtension( 'foo.lol', '.wut' ), 'foo.lol' );
});
});
Loading