From 4ed4461b2660690f69941b2fd4665cf4aee1dc28 Mon Sep 17 00:00:00 2001 From: Harm van der Werf Date: Wed, 25 Apr 2018 02:06:44 +0200 Subject: [PATCH] Added type definitions for Chai UUID (#25227) * Added types for Chai UUID * Fixed the test file * Removed the message parameter because it's not implemented in the plugin * Removed an empty namespace as it was unnecessary --- types/chai-uuid/chai-uuid-tests.ts | 15 +++++++++++++++ types/chai-uuid/index.d.ts | 27 +++++++++++++++++++++++++++ types/chai-uuid/tsconfig.json | 23 +++++++++++++++++++++++ types/chai-uuid/tslint.json | 1 + 4 files changed, 66 insertions(+) create mode 100644 types/chai-uuid/chai-uuid-tests.ts create mode 100644 types/chai-uuid/index.d.ts create mode 100644 types/chai-uuid/tsconfig.json create mode 100644 types/chai-uuid/tslint.json diff --git a/types/chai-uuid/chai-uuid-tests.ts b/types/chai-uuid/chai-uuid-tests.ts new file mode 100644 index 0000000000..0620464988 --- /dev/null +++ b/types/chai-uuid/chai-uuid-tests.ts @@ -0,0 +1,15 @@ +import { assert, expect, use, should } from 'chai'; +import chaiUuid = require('chai-uuid'); + +use(chaiUuid); +should(); + +// bdd style +expect('67cb8aa1-61bb-4b9b-8ca9-9dc0b278d5f7').to.be.uuid('v4'); +expect('67cb8aa1-61bb-4b9b-8ca9-9dc0b278d5f7').to.be.guid; +expect('invalid').to.not.be.uuid('v4'); +expect('invalid').to.not.be.guid(); + +// tdd style +assert.uuid('67cb8aa1-61bb-4b9b-8ca9-9dc0b278d5f7', 'v4'); +assert.guid('67cb8aa1-61bb-4b9b-8ca9-9dc0b278d5f7'); diff --git a/types/chai-uuid/index.d.ts b/types/chai-uuid/index.d.ts new file mode 100644 index 0000000000..23a0b6db92 --- /dev/null +++ b/types/chai-uuid/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for chai-uuid 1.0 +// Project: https://github.com/rfrench/chai-uuid +// Definitions by: Harm van der Werf +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +/// +/// + +declare global { + namespace Chai { + type UuidVersion = 'v1' | 'v2' | 'v3' | 'v4' | 'v5' | ''; + + interface Assertion extends LanguageChains, NumericComparison, TypeComparison { + uuid(uuid?: UuidVersion): void; + guid(guid?: any): void; + } + + interface Assert { + uuid(uuid: string, version?: UuidVersion): void; + guid(guid: string, version?: any): void; + } + } +} + +declare function chaiUuid(chai: any, utils: any): void; +export = chaiUuid; diff --git a/types/chai-uuid/tsconfig.json b/types/chai-uuid/tsconfig.json new file mode 100644 index 0000000000..ca2ca40071 --- /dev/null +++ b/types/chai-uuid/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "chai-uuid-tests.ts" + ] +} diff --git a/types/chai-uuid/tslint.json b/types/chai-uuid/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/chai-uuid/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }