Skip to content

Commit

Permalink
fix(jest mock): Add stub for static content
Browse files Browse the repository at this point in the history
Update PR based on latest code
  • Loading branch information
michaelw85 committed Mar 25, 2019
1 parent b7aa152 commit 473a540
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion skeleton/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"devDependencies": {
"jest": "",
"jest-cli": "",
"jest-transform-stub": "",
"aurelia-loader-nodejs": "",
"aurelia-pal-nodejs": "",

Expand Down Expand Up @@ -34,6 +35,7 @@
"json"
],
"transform": {
"^.+\\.(css|less|sass|scss|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "jest-transform-stub",
// @if feat.babel
"^.+\\.js$": "babel-jest",
// @endif
Expand Down Expand Up @@ -81,4 +83,4 @@
"html"
]
}
}
}
25 changes: 25 additions & 0 deletions skeleton/scaffold-minimum/test__if_karma_or_jest/unit/app.spec.ext
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
import {bootstrap} from 'aurelia-bootstrapper';
import {App} from '../../src/app';
import {StageComponent} from 'aurelia-testing';

describe('the app', () => {
it('says hello', () => {
expect(new App().message).toBe('Hello World!');
});
});

describe('Stage App Component', () => {
let component;

beforeEach(() => {
component = StageComponent
.withResources('app')
.inView('<app></app>');
});

afterEach(() => component.dispose());

it('should render message', done => {
component.create(bootstrap).then(() => {
const view = component.element;
expect(view.textContent.trim()).toBe('Hello World!');
done();
}).catch(e => {
fail(e);
done();
});
});
});

0 comments on commit 473a540

Please sign in to comment.