Skip to content

Commit

Permalink
Hook up test
Browse files Browse the repository at this point in the history
  • Loading branch information
jassmith committed Mar 26, 2022
1 parent af2b98b commit b14ab68
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 66 deletions.
1 change: 1 addition & 0 deletions .github/workflows/node.js.yml
Expand Up @@ -21,6 +21,7 @@ jobs:
- run: npm run bootstrap
- run: npm run build
- run: npm run test -- --coverage
- run: npm run test-source
- run: npm run test-projects
- name: Coveralls
uses: coverallsapp/github-action@master
Expand Down
5 changes: 3 additions & 2 deletions bootstrap.sh
Expand Up @@ -25,7 +25,8 @@ do
npm ci
update ".dependencies.\"@glideapps/glide-data-grid\" = $VERSION" package.json
update ".version = $VERSION" package.json
rm -rf node_modules/@glideapps/glide-data-grid
ln -s ../../../core node_modules/@glideapps/glide-data-grid
rm -rf node_modules/@glideapps/glide-data-grid/*
ln -s ../../../../core/dist node_modules/@glideapps/glide-data-grid/dist
ln -s ../../../../core/package.json node_modules/@glideapps/glide-data-grid/package.json
popd
done
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -8,6 +8,7 @@
"build-storybook": "build-storybook -o storybook-build/",
"prod-storybook": "npm run build-storybook && npx http-server storybook-build -p 9009",
"test": "cd packages/core && npm run test --",
"test-source": "cd packages/source && npm run test",
"test-projects": "cd test-projects/ && ./bootstrap-projects.sh"
},
"author": "Glide",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/jest.config.js
Expand Up @@ -4,7 +4,7 @@ export default {
testEnvironment: "jsdom",
moduleDirectories: ["node_modules", "../node_modules"],
setupFilesAfterEnv: ["<rootDir>/src/setupTests.ts"],
testPathIgnorePatterns: ["/node_modules/", "/ts-build/"],
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
transform: {
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest",
Expand Down
12 changes: 9 additions & 3 deletions packages/source/jest.config.js
@@ -1,12 +1,18 @@
export default {
preset: "ts-jest",
preset: "ts-jest/presets/default-esm",
roots: ["<rootDir>/"],
testEnvironment: "jsdom",
moduleDirectories: ["node_modules", "../node_modules"],
setupFilesAfterEnv: ["<rootDir>/src/setupTests.ts"],
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
extensionsToTreatAsEsm: [".ts", ".tsx"],
transform: {
"^.+\\.[t|j]sx?$": ["babel-jest", { configFile: "../../babel.config.json" }],
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest",
},
extensionsToTreatAsEsm: [".ts", ".tsx"],
globals: {
"ts-jest": {
useESM: true,
},
},
};
114 changes: 57 additions & 57 deletions packages/source/package.json
@@ -1,59 +1,59 @@
{
"name": "@glideapps/glide-data-grid-source",
"version": "4.0.0-alpha1",
"description": "Useful data source hooks for Glide Data Grid",
"sideEffects": false,
"type": "module",
"main": "dist/js/index.js",
"types": "dist/ts/index.d.ts",
"exports": {
"import": "./dist/js/index.js",
"require": "./dist/cjs/index.js"
},
"files": [
"dist"
],
"scripts": {
"build": "npm run build-js && npm run build-cjs && npm run build-types",
"build-js": "babel --config-file ../../babel.config.json ./src -d dist/js --ignore '**/*.stories.tsx','src/stories/*.tsx' --extensions .ts,.tsx && tsc-esm-fix --target='dist/js'",
"build-cjs": "babel --config-file ../../babel.cjs.json ./src -d dist/cjs --ignore '**/*.stories.tsx','src/stories/*.tsx' --extensions .ts,.tsx",
"build-types": "tsc -p tsconfig.types.json",
"lint": "eslint src --ext .ts,.tsx",
"test": "NODE_OPTIONS='--experimental-vm-modules --experimental-modules' jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/glideapps/glide-data-grid.git",
"directory": "packages/source"
},
"homepage": "https://github.com/glideapps/glide-data-grid/tree/main/cells",
"author": "Glide",
"license": "MIT",
"keywords": [
"react",
"datagrid",
"data-grid",
"editor",
"reactjs",
"scrolling",
"data",
"table",
"cell",
"canvas"
],
"dependencies": {
"@glideapps/glide-data-grid": "4.0.0-alpha1"
},
"peerDependencies": {
"lodash": "^4.17.19"
},
"devDependencies": {
"@babel/cli": "^7.16.0",
"styled-components": "^5.2.0",
"eslint": "^7.12.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"jest": "^27.4.2"
}
"name": "@glideapps/glide-data-grid-source",
"version": "4.0.0-alpha1",
"description": "Useful data source hooks for Glide Data Grid",
"sideEffects": false,
"type": "module",
"main": "dist/js/index.js",
"types": "dist/ts/index.d.ts",
"exports": {
"import": "./dist/js/index.js",
"require": "./dist/cjs/index.js"
},
"files": [
"dist"
],
"scripts": {
"build": "npm run build-js && npm run build-cjs && npm run build-types",
"build-js": "babel --config-file ../../babel.config.json ./src -d dist/js --ignore '**/*.stories.tsx','src/stories/*.tsx' --extensions .ts,.tsx && tsc-esm-fix --target='dist/js'",
"build-cjs": "babel --config-file ../../babel.cjs.json ./src -d dist/cjs --ignore '**/*.stories.tsx','src/stories/*.tsx' --extensions .ts,.tsx",
"build-types": "tsc -p tsconfig.types.json",
"lint": "eslint src --ext .ts,.tsx",
"test": "NODE_OPTIONS='--experimental-vm-modules --experimental-modules' jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/glideapps/glide-data-grid.git",
"directory": "packages/source"
},
"homepage": "https://github.com/glideapps/glide-data-grid/tree/main/cells",
"author": "Glide",
"license": "MIT",
"keywords": [
"react",
"datagrid",
"data-grid",
"editor",
"reactjs",
"scrolling",
"data",
"table",
"cell",
"canvas"
],
"dependencies": {
"@glideapps/glide-data-grid": "4.0.0-alpha1"
},
"peerDependencies": {
"lodash": "^4.17.19"
},
"devDependencies": {
"@babel/cli": "^7.16.0",
"styled-components": "^5.2.0",
"eslint": "^7.12.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"jest": "^27.4.2"
}
}
9 changes: 7 additions & 2 deletions packages/source/src/setupTests.ts
@@ -1,4 +1,9 @@
import "@testing-library/jest-dom";
import "jest-canvas-mock";
import { jest } from "jest-without-globals";

Image.prototype.decode = () => new Promise(resolve => window.setTimeout(resolve, 10));
jest.mock("styled-components", () => {
const actual = jest.requireActual("styled-components") as typeof import("styled-components");
const styled = actual.default;

return Object.assign(styled, actual);
});
2 changes: 1 addition & 1 deletion packages/source/src/use-data-source.test.tsx
Expand Up @@ -103,6 +103,6 @@ describe("use-data-source", () => {

const zeroZero = screen.getByTestId("cell-0-0");

expect(zeroZero.textContent).toBe("Test fails");
expect(zeroZero.textContent).toBe("0x0");
});
});

0 comments on commit b14ab68

Please sign in to comment.