Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epidemian
GitHub Repository: epidemian/eslint-plugin-import
Path: blob/main/resolvers/node/test/packageMains.js
829 views
1
'use strict';
2
3
const chai = require('chai');
4
const expect = chai.expect;
5
const path = require('path');
6
7
const resolver = require('../');
8
9
const file = path.join(__dirname, 'package-mains', 'dummy.js');
10
11
12
describe('packageMains', function () {
13
it('captures module', function () {
14
expect(resolver.resolve('./module', file)).property('path')
15
.to.equal(path.join(__dirname, 'package-mains', 'module', 'src', 'index.js'));
16
});
17
18
it('captures jsnext', function () {
19
expect(resolver.resolve('./jsnext', file)).property('path')
20
.to.equal(path.join(__dirname, 'package-mains', 'jsnext', 'src', 'index.js'));
21
});
22
23
it('captures module instead of jsnext', function () {
24
expect(resolver.resolve('./module-and-jsnext', file)).property('path')
25
.to.equal(path.join(__dirname, 'package-mains', 'module-and-jsnext', 'src', 'index.js'));
26
});
27
28
it('falls back from a missing "module" to "main"', function () {
29
expect(resolver.resolve('./module-broken', file)).property('path')
30
.to.equal(path.join(__dirname, 'package-mains', 'module-broken', 'main.js'));
31
});
32
});
33
34