Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions formidable/auth/imba/test/__mocks__/@paralleldrive/cuid2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//Mock for @paralleldrive/cuid2

module.exports = {
createId: jest.fn(() => 'mock-id'),
init: jest.fn(),
getConstants: jest.fn(() => ({})),
isCuid: jest.fn(() => true)
};
2 changes: 2 additions & 0 deletions formidable/auth/imba/test/app.e2e.test.imba
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock '@paralleldrive/cuid2'

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand Down
8 changes: 8 additions & 0 deletions formidable/auth/ts/test/__mocks__/@paralleldrive/cuid2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//Mock for @paralleldrive/cuid2

module.exports = {
createId: jest.fn(() => 'mock-id'),
init: jest.fn(),
getConstants: jest.fn(() => ({})),
isCuid: jest.fn(() => true)
};
2 changes: 2 additions & 0 deletions formidable/auth/ts/test/app.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock('@paralleldrive/cuid2')

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand Down
8 changes: 8 additions & 0 deletions formidable/web/test/imba/__mocks__/@paralleldrive/cuid2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//Mock for @paralleldrive/cuid2

module.exports = {
createId: jest.fn(() => 'mock-id'),
init: jest.fn(),
getConstants: jest.fn(() => ({})),
isCuid: jest.fn(() => true)
};
2 changes: 2 additions & 0 deletions formidable/web/test/imba/app.e2e.test.imba
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock '@paralleldrive/cuid2'

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand Down
8 changes: 8 additions & 0 deletions formidable/web/test/ts/__mocks__/@paralleldrive/cuid2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//Mock for @paralleldrive/cuid2

module.exports = {
createId: jest.fn(() => 'mock-id'),
init: jest.fn(),
getConstants: jest.fn(() => ({})),
isCuid: jest.fn(() => true)
};
4 changes: 3 additions & 1 deletion formidable/web/test/ts/app.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock('@paralleldrive/cuid2')

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand All @@ -17,7 +19,7 @@ describe('Application (e2e)', () => {
})

it('/ (GET: Welcome)', async () => {
supertest(app.server)
await supertest(app.server)
.get('/')
.expect(200)
.expect((res) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@formidablejs/framework",
"version": "0.28.4",
"version": "0.28.5",
"description": "Formidable Framework Core",
"author": "Donald Pakkies",
"license": "MIT",
Expand Down
8 changes: 8 additions & 0 deletions scripts/e2e/test/__mocks__/@paralleldrive/cuid2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//Mock for @paralleldrive/cuid2

module.exports = {
createId: jest.fn(() => 'mock-id'),
init: jest.fn(),
getConstants: jest.fn(() => ({})),
isCuid: jest.fn(() => true)
};
2 changes: 2 additions & 0 deletions scripts/e2e/test/app.e2e.test.imba
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock '@paralleldrive/cuid2'

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand Down
2 changes: 2 additions & 0 deletions scripts/e2e/test/auth.test.imba
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock '@paralleldrive/cuid2'

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand Down
2 changes: 2 additions & 0 deletions scripts/e2e/test/database.test.imba
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock '@paralleldrive/cuid2'

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand Down
2 changes: 2 additions & 0 deletions scripts/e2e/test/language.test.imba
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock '@paralleldrive/cuid2'

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand Down
2 changes: 2 additions & 0 deletions scripts/e2e/test/responses.test.imba
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock '@paralleldrive/cuid2'

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand Down
2 changes: 2 additions & 0 deletions scripts/e2e/test/routes.test.imba
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock '@paralleldrive/cuid2'

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand Down
2 changes: 2 additions & 0 deletions scripts/e2e/test/validation.test.imba
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock '@paralleldrive/cuid2'

const formidable = require('../.formidable/build').default
const supertest = require('supertest')

Expand Down
5 changes: 4 additions & 1 deletion src/Support/Helpers/config.imba
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ConfigNotCachedError from './Error/ConfigNotCachedError'
import dot from './dotNotation'
import runtime from './runtime'
import path from 'path'

def fallback notation\string, default\any = null
Expand All @@ -15,7 +16,9 @@ export default def config notation\string, default\any = null
if !notation or typeof notation != 'string'
return default
try
const config = require(path.join(process.cwd!, 'bootstrap', 'cache', 'config.json'))
const cachedConfig = path.join(process.cwd!, 'bootstrap', 'cache', 'config.json')

const config = runtime() == 'bun' ? JSON.parse(fs.readFileSync(cachedConfig)) : require(cachedConfig)
return dot(config, notation) ?? default
catch e
return fallback(notation, default)
5 changes: 4 additions & 1 deletion src/Support/Language/Language.imba
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dot from '../Helpers/dotNotation'
import runtime from '../Helpers/runtime'
import fs from 'fs'
import path from 'path'

Expand Down Expand Up @@ -46,8 +47,10 @@ export default class Language

for file in fs.readdirSync(path.join(location, pack))
if path.extname(file) == '.json'
const translation = path.join(location, pack, file)

const definition = {
[path.parse(file).name]: require path.join(location, pack, file)
[path.parse(file).name]: runtime! == 'bun' ? JSON.parse(fs.readFileSync(translation).toString()) : require(translation)
}

if !definition
Expand Down