Skip to content

Commit

Permalink
fix: Move to BrightspaceUI/testing (#186)
Browse files Browse the repository at this point in the history
* Move to BrightspaceUI/testing

* Regenerate package-lock

* Use shared testing eslint config

* Cleanup
  • Loading branch information
bearfriend authored Aug 22, 2024
1 parent 8d3b029 commit 63f9fac
Show file tree
Hide file tree
Showing 10 changed files with 3,271 additions and 1,807 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "brightspace/browser-config"
"extends": "brightspace/browser-config",
"overrides": [{
"files": "test/*",
"extends": "brightspace/testing-config"
}]
}
4,996 changes: 3,246 additions & 1,750 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"scripts": {
"lint": "eslint . --ext .js",
"start": "web-dev-server --node-resolve --watch --open /demo/",
"test:unit": "concurrently -p name -n serve,test -s first -k \"http-server -p 8080 . -s\" \"mocha-headless-chrome -f http://localhost:8080/test/index.html -a no-sandbox -a disable-setuid-sandbox\"",
"test": "npm run lint -s && npm run test:unit -s"
"test:unit": "d2l-test-runner",
"test": "npm run lint && npm run test:unit"
},
"files": [
"/lib"
Expand Down Expand Up @@ -37,15 +37,8 @@
},
"homepage": "https://github.com/BrightspaceUI/intl",
"devDependencies": {
"@babel/core": "^7",
"@babel/eslint-parser": "^7",
"@web/dev-server": "^0.4",
"chai": "^5",
"concurrently": "^8",
"@brightspace-ui/testing": "^1",
"eslint": "^8",
"eslint-config-brightspace": "^1.0",
"http-server": "^14.0",
"mocha": "^10",
"mocha-headless-chrome": "^4"
"eslint-config-brightspace": "^1"
}
}
8 changes: 0 additions & 8 deletions test/.eslintrc.json

This file was deleted.

11 changes: 8 additions & 3 deletions test/common.js → test/common.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {
supportedBaseLocales,
supportedLocales
} from '../lib/common.js';

const expect = chai.expect;
import { expect } from '@brightspace-ui/testing';

describe('common', () => {

Expand Down Expand Up @@ -138,6 +137,9 @@ describe('common', () => {
documentLocaleSettings.removeChangeListener(cb);
done();
};
htmlElem.removeAttribute('lang');
documentLocaleSettings._languageInitial = null;
documentLocaleSettings.reset();
documentLocaleSettings.addChangeListener(cb);
htmlElem.setAttribute('data-lang-default', 'de');
});
Expand Down Expand Up @@ -173,7 +175,7 @@ describe('common', () => {
documentLocaleSettings.addChangeListener(cb);
htmlElem.setAttribute('lang', 'es');
});
it('should use default if "fallback" is removed', (done) => {
it('should use default if "lang" is not set and "fallback" is removed', (done) => {
let count = 0;
const cb = () => {
count++;
Expand All @@ -186,6 +188,9 @@ describe('common', () => {
done();
}
};
htmlElem.removeAttribute('lang');
documentLocaleSettings._languageInitial = null;
documentLocaleSettings.reset();
documentLocaleSettings.addChangeListener(cb);
htmlElem.setAttribute('data-lang-default', 'es');
});
Expand Down
11 changes: 5 additions & 6 deletions test/dateTime.js → test/dateTime.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import {
parseDate,
parseTime
} from '../lib/dateTime.js';
import { expect } from '@brightspace-ui/testing';
import { getDocumentLocaleSettings } from '../lib/common.js';

const expect = chai.expect;

describe('dateTime', () => {

const documentLocaleSettings = getDocumentLocaleSettings();
Expand Down Expand Up @@ -1034,14 +1033,14 @@ describe('dateTime', () => {
[hoursAgo(5.49), '5 hours ago'],
[hoursAgo(5.51), 'yesterday'],
[hoursAgo(23.51), 'yesterday'],
[new Date('12/31/2022, 12:00:00:000 AM'), 'yesterday'],
[new Date('12/30/2022, 11:59:59:999 PM'), '1 day ago'],
[new Date('12/31/2022, 12:00:00 AM'), 'yesterday'],
[new Date('12/30/2022, 11:59:59 PM'), '1 day ago'],
[daysAgo(1.49), '1 day ago'],
[daysAgo(1.51), '2 days ago'],
[daysAgo(3.51), 'last week'],
[daysAgo(6.51), 'last week'],
[new Date('12/25/2022, 12:00:00:000 AM'), 'last week'],
[new Date('12/24/2022, 11:59:59:999 PM'), '1 week ago'],
[new Date('12/25/2022, 12:00:00 AM'), 'last week'],
[new Date('12/24/2022, 11:59:59 PM'), '1 week ago'],
[weeksAgo(1.49), '1 week ago'],
[weeksAgo(1.51), '2 weeks ago'],
[weeksAgo(3.49), '3 weeks ago'],
Expand Down
3 changes: 1 addition & 2 deletions test/fileSize.js → test/fileSize.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { expect } from '@brightspace-ui/testing';
import { formatFileSize } from '../lib/fileSize.js';
import { getDocumentLocaleSettings } from '../lib/common.js';

const expect = chai.expect;

describe('formatFileSize', () => {

const documentLocaleSettings = getDocumentLocaleSettings();
Expand Down
22 changes: 0 additions & 22 deletions test/index.html

This file was deleted.

3 changes: 1 addition & 2 deletions test/list.js → test/list.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { expect } from '@brightspace-ui/testing';
import { getDocumentLocaleSettings } from '../lib/common.js';
import { getSeparator } from '../lib/list.js';

const expect = chai.expect;

describe('getSeparator', () => {

const documentLocaleSettings = getDocumentLocaleSettings();
Expand Down
3 changes: 1 addition & 2 deletions test/number.js → test/number.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { formatNumber, formatPercent, parseNumber } from '../lib/number.js';
import { expect } from '@brightspace-ui/testing';
import { getDocumentLocaleSettings } from '../lib/common.js';

const expect = chai.expect;

describe('number', () => {

const documentLocaleSettings = getDocumentLocaleSettings();
Expand Down

0 comments on commit 63f9fac

Please sign in to comment.