Skip to content

Commit

Permalink
Merge pull request #11 from saleem-hadad/feature/ui-unit-testing
Browse files Browse the repository at this point in the history
✍️ Add UI unit tests #feature
  • Loading branch information
saleem-hadad authored Apr 22, 2022
2 parents ee052e8 + 61f9ada commit 06b02cd
Show file tree
Hide file tree
Showing 60 changed files with 1,312 additions and 417 deletions.
5 changes: 4 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
["@babel/transform-runtime"]
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ npm-debug.log
yarn-error.log
/.idea
/.vscode
coverage
2 changes: 1 addition & 1 deletion graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Query {
transactions: [Transaction!]! @paginate(defaultCount: 25) @orderBy(column: id direction: DESC)

allBrands: [Brand!]! @all
brands: [Brand!]! @paginate(defaultCount: 25) @orderBy(column: category_id direction: ASC)
brands: [Brand!]! @paginate(defaultCount: 25) @orderBy(column: id direction: DESC)

allCategories: [Category!]! @all
categories: [Category!]! @paginate(defaultCount: 25) @orderBy(column: id direction: DESC)
Expand Down
643 changes: 625 additions & 18 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"test": "jest --env=jsdom"
"test": "jest --env=jsdom --colors --coverage"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@headlessui/react": "^1.4.2",
Expand All @@ -23,9 +24,12 @@
"autoprefixer": "^10.2.4",
"axios": "^0.21",
"babel-jest": "^27.5.1",
"intersection-observer": "^0.12.0",
"isomorphic-unfetch": "^3.1.0",
"jest": "^27.5.1",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"msw": "^0.39.2",
"postcss": "^8.2.13",
"postcss-import": "^14.0.1",
"react": "^17.0.2",
Expand All @@ -34,10 +38,12 @@
"tailwindcss": "^3.0.0"
},
"dependencies": {
"@babel/runtime": "^7.17.9",
"@heroicons/react": "^1.0.5",
"chart.js": "^3.7.0",
"graphql": "^16.2.0",
"graphql": "^16.3.0",
"numbro": "^2.3.6",
"react-chartjs-2": "^4.0.0"
"react-chartjs-2": "^4.0.0",
"urql": "^2.2.0"
}
}
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/app.js": "/js/app.js?id=d80c6aa68ccfd74342c8",
"/css/app.css": "/css/app.css?id=9980ba94755724b3d676"
"/js/app.js": "/js/app.js?id=646cbe42f9883c5bee75",
"/css/app.css": "/css/app.css?id=302229d53296b2231e13"
}
216 changes: 0 additions & 216 deletions resources/js/Api.js

This file was deleted.

74 changes: 74 additions & 0 deletions resources/js/Api/brands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { gql } from '@urql/core';
import client from './client.js';

export const getAllBrands = () => {
return client
.query(gql`
query {
allBrands {
id
name
category {
name
}
}
}
`)
.toPromise();
}

export const getBrands = (page) => {
return client
.query(gql`
query {
brands(page: ${page}) {
data {
id
name
category {
id
name
}
}
paginatorInfo {
hasMorePages
}
}
}
`)
.toPromise();
}

export const createBrand = ({name, categoryId}) => {
return client
.mutation(gql`
mutation {
createBrand(name: """${name}""" category_id: ${categoryId}) {
id
name
category {
id
name
}
}
}
`)
.toPromise();
}

export const updateBrand = ({id, name, category}) => {
return client
.mutation(gql`
mutation {
updateBrand(id: ${id} name: "${name}" category_id: ${category}) {
id
name
category {
id
name
}
}
}
`)
.toPromise();
}
Loading

0 comments on commit 06b02cd

Please sign in to comment.