test(core): init stencil core test suite

This commit is contained in:
Adam Bradley
2017-09-26 22:12:36 -05:00
parent ff7b05ed23
commit d3e79fb462
3 changed files with 2962 additions and 96 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10,10 +10,12 @@
"dist/" "dist/"
], ],
"devDependencies": { "devDependencies": {
"@stencil/core": "0.0.6-0", "@stencil/core": "0.0.6-2",
"@stencil/dev-server": "latest", "@stencil/dev-server": "latest",
"@stencil/utils": "latest", "@stencil/utils": "latest",
"@types/jest": "^21.1.0",
"ionicons": "^4.0.0-6", "ionicons": "^4.0.0-6",
"jest": "^21.1.0",
"sass-lint": "^1.11.1", "sass-lint": "^1.11.1",
"tslint": "^5.7.0", "tslint": "^5.7.0",
"tslint-ionic-rules": "0.0.11" "tslint-ionic-rules": "0.0.11"
@ -22,6 +24,7 @@
"build": "stencil build", "build": "stencil build",
"dev": "sd concurrent \"stencil build --dev --watch\" \"stencil-dev-server\"", "dev": "sd concurrent \"stencil build --dev --watch\" \"stencil-dev-server\"",
"test": "jest --no-cache", "test": "jest --no-cache",
"test.watch": "jest --watch --no-cache",
"clean": "rm -rf dist", "clean": "rm -rf dist",
"lint": "npm run tslint", "lint": "npm run tslint",
"sass-lint": "sass-lint -v -q", "sass-lint": "sass-lint -v -q",
@ -40,5 +43,17 @@
"bugs": { "bugs": {
"url": "https://github.com/ionic-team/ionic/issues" "url": "https://github.com/ionic-team/ionic/issues"
}, },
"homepage": "https://github.com/ionic-team/ionic#readme" "homepage": "https://github.com/ionic-team/ionic#readme",
"jest": {
"transform": {
"^.+\\.(ts|tsx)$": "<rootDir>/node_modules/@stencil/core/testing/jest.preprocessor.js"
},
"testRegex": ".*\\.spec\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx"
]
}
} }

View File

@ -0,0 +1,27 @@
import { render, flush } from '@stencil/core/testing';
import { Button } from '../button';
describe('button', () => {
it('should render button inner text', async () => {
const root = await render({
components: [Button],
html: '<ion-button>Button Inner Text</ion-button>'
});
expect(root.textContent).toBe('Button Inner Text');
expect(root.querySelector('button').hasAttribute('disabled')).toBe(false);
root.disabled = true;
await flush(root);
expect(root.querySelector('button').hasAttribute('disabled')).toBe(true);
});
it('should default itemButton to false', () => {
const btn = new Button();
expect(btn.itemButton).toBe(false);
});
});