Skip to content

Commit

Permalink
refactor: fix breaking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jul 18, 2019
1 parent dad019b commit 431029b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"ts-node": "^8.3.0",
"tslint": "^5.18.0",
"tslint-eslint-rules": "^5.4.0",
"typescript": "^3.5.2"
"typescript": "^3.5.3"
},
"nyc": {
"exclude": [
Expand Down
52 changes: 26 additions & 26 deletions test/fixtures/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import { IncomingMessage } from 'http'
import { Assert } from 'japa/build/src/Assert'

import { CorsConfig } from '@ioc:Adonis/Core/Cors'
import { corsConfig } from '../../config/cors'
import { CorsConfigContract } from '@ioc:Adonis/Core/Cors'
import corsConfig from '../../config/cors'

const CORS_HEADERS = [
'access-control-allow-origin',
Expand All @@ -30,7 +30,7 @@ export const specFixtures = [
{
title: 'do not set any headers when origin is not defined',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig)
},

Expand All @@ -48,7 +48,7 @@ export const specFixtures = [
{
title: 'do not set any headers when origin mis-matches',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: 'adonisjs.com',
})
Expand All @@ -71,7 +71,7 @@ export const specFixtures = [
{
title: 'do not set any headers when all origins are dis-allowed',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: false,
})
Expand All @@ -94,7 +94,7 @@ export const specFixtures = [
{
title: 'do not set headers when origin case sensitive match fails',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: 'foo.com',
})
Expand All @@ -117,7 +117,7 @@ export const specFixtures = [
{
title: 'do not set headers when current origin isn\'t inside array of allowed origins',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: ['foo.com'],
})
Expand All @@ -140,7 +140,7 @@ export const specFixtures = [
{
title: 'allow all origins when origin is set to true',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
})
Expand All @@ -165,7 +165,7 @@ export const specFixtures = [
{
title: 'allow origin when current origin is in allowed array list',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: ['foo.com', 'bar.com'],
})
Expand All @@ -190,7 +190,7 @@ export const specFixtures = [
{
title: 'allow origin when current origin is in allowed comma seperated list',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: 'foo.com,bar.com',
})
Expand All @@ -215,7 +215,7 @@ export const specFixtures = [
{
title: 'allow origin when config function returns true',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: () => true,
})
Expand All @@ -240,7 +240,7 @@ export const specFixtures = [
{
title: 'set current origin when using wildcard identifier with credentails=true',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: '*',
})
Expand All @@ -266,7 +266,7 @@ export const specFixtures = [
{
title: 'set wildcard when using wildcard identifier with credentails=false',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: '*',
credentials: false,
Expand All @@ -293,7 +293,7 @@ export const specFixtures = [
{
title: 'set expose headers when defined',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: '*',
exposeHeaders: ['X-Adonis'],
Expand Down Expand Up @@ -326,7 +326,7 @@ export const specFixtures = [
{
title: 'set required preflight headers when request method exists',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
})
Expand Down Expand Up @@ -359,7 +359,7 @@ export const specFixtures = [
{
title: 'do not set preflight headers when request method isn\'t allowed',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
})
Expand Down Expand Up @@ -388,7 +388,7 @@ export const specFixtures = [
{
title: 'do not set preflight headers when all of the request headers are not allowed',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
headers: false,
Expand Down Expand Up @@ -419,7 +419,7 @@ export const specFixtures = [
{
title: 'do not set preflight headers when any of the request headers are not allowed',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
headers: ['cache-control'],
Expand Down Expand Up @@ -450,7 +450,7 @@ export const specFixtures = [
{
title: 'set preflight headers when all of the request headers are allowed',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
headers: true,
Expand Down Expand Up @@ -487,7 +487,7 @@ export const specFixtures = [
{
title: 'set preflight headers when request headers is in the list of allowed headers',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
headers: ['X-Adonis'],
Expand Down Expand Up @@ -524,7 +524,7 @@ export const specFixtures = [
{
title: 'set preflight headers when request headers is in the list of comma seperated list',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
headers: 'X-Adonis,X-Time',
Expand Down Expand Up @@ -561,7 +561,7 @@ export const specFixtures = [
{
title: 'set preflight headers when case insensitive match passes',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
headers: ['x-adonis'],
Expand Down Expand Up @@ -598,7 +598,7 @@ export const specFixtures = [
{
title: 'set all allow headers when request header match passes',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
headers: ['x-adonis', 'x-foo', 'x-bar'],
Expand Down Expand Up @@ -635,7 +635,7 @@ export const specFixtures = [
{
title: 'set allow headers when headers config function returns true',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
headers: () => true,
Expand Down Expand Up @@ -672,7 +672,7 @@ export const specFixtures = [
{
title: 'set max age when defined',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
headers: () => true,
Expand Down Expand Up @@ -710,7 +710,7 @@ export const specFixtures = [
{
title: 'set expose headers when defined',

configureOptions (): CorsConfig {
configureOptions (): CorsConfigContract {
return Object.assign({}, corsConfig, {
origin: true,
headers: () => true,
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "./node_modules/@adonisjs/mrm-preset/_tsconfig"
"extends": "./node_modules/@adonisjs/mrm-preset/_tsconfig",
"compilerOptions": {
"skipLibCheck": true
}
}

0 comments on commit 431029b

Please sign in to comment.