type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
(_: ApolloError) => { const { data, optimisticData } = client.cache as any; expect(optimisticData).toBe(data.stump); resolve(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { const client = new ApolloClient({ link: ApolloLink.empty(), cache: new InMemoryCache(), }); // @ts-ignore const spy = jest.spyOn(client.queryManager, 'clearStore'); await client.clearStore(); expect(spy).toHaveBeenCalled(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { const client = new ApolloClient({ link: ApolloLink.empty(), cache: new InMemoryCache(), }); const onClearStore = jest.fn(); client.onClearStore(onClearStore); await client.clearStore(); expect(onClearStore).toHaveBeenCalled(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { const client = new ApolloClient({ link: ApolloLink.empty(), cache: new InMemoryCache(), }); const onClearStore = jest.fn(); const unsubscribe = client.onClearStore(onClearStore); unsubscribe(); await client.clearStore(); expect(onClearStore).not.toHaveBeenCalled...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { const client = new ApolloClient({ link: ApolloLink.empty(), cache: new InMemoryCache(), }); // @ts-ignore const spy = jest.spyOn(client.queryManager, 'clearStore'); await client.resetStore(); expect(spy).toHaveBeenCalled(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { const client = new ApolloClient({ link: ApolloLink.empty(), cache: new InMemoryCache(), }); const onResetStore = jest.fn(); client.onResetStore(onResetStore); await client.resetStore(); expect(onResetStore).toHaveBeenCalled(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { const client = new ApolloClient({ link: ApolloLink.empty(), cache: new InMemoryCache(), }); const onResetStore = jest.fn(); const unsubscribe = client.onResetStore(onResetStore); unsubscribe(); await client.resetStore(); expect(onResetStore).not.toHaveBeenCalled...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { const delay = (time: number) => new Promise(r => setTimeout(r, time)); const client = new ApolloClient({ link: ApolloLink.empty(), cache: new InMemoryCache(), }); let count = 0; const onResetStoreOne = jest.fn(async () => { expect(count).toEqual(0); await del...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(time: number) => new Promise(r => setTimeout(r, time))
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
r => setTimeout(r, time)
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { expect(count).toEqual(0); await delay(10).then(() => count++); expect(count).toEqual(1); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => count++
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { expect(count).toEqual(0); await delay(11).then(() => count++); expect(count).toEqual(2); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async (resolve, reject) => { const delay = (time: number) => new Promise(r => setTimeout(r, time)); const query = gql` query { author { firstName lastName } } `; const data = { author: { __typename: 'Author', firstName: 'John', ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => new Observable(observer => { observer.next({ data }); observer.complete(); return; })
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
observer => { observer.next({ data }); observer.complete(); return; }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { expect(count).toEqual(0); await delay(11).then(() => count++); expect(count).toEqual(2); expect(client.readQuery({ query })).toBe(null); client.cache.writeQuery({ query, data: data2 }); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
d => { if (called) { expect(onResetStoreOne).toHaveBeenCalled(); } else { expect(d.data).toEqual(data); called = true; } }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { const client = new ApolloClient({ link: ApolloLink.empty(), cache: new InMemoryCache(), }); // @ts-ignore const spy = jest.spyOn(client.queryManager, 'reFetchObservableQueries'); await client.reFetchObservableQueries(); expect(spy).toHaveBeenCalled(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { const client = new ApolloClient({ link: ApolloLink.empty(), cache: new InMemoryCache(), }); const spy = jest.spyOn(client['queryManager'], 'refetchQueries'); spy.mockImplementation(() => new Map); const options = { include: ['Author1'] }; await client.refetchQueries(...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => new Map
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async () => { const client = new ApolloClient({ link: ApolloLink.empty(), cache: new InMemoryCache(), }); // @ts-ignore const spy = jest.spyOn(client.queryManager, 'getObservableQueries'); await client.getObservableQueries(); expect(spy).toHaveBeenCalled(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const link = ApolloLink.from([ () => new Observable(x => { x.error(new Error('Uh oh!')); return; }), ]); const client = new ApolloClient({ link, cache: new InMemoryCache({ addTypename: false }), }); const handle = client...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => new Observable(x => { x.error(new Error('Uh oh!')); return; })
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
x => { x.error(new Error('Uh oh!')); return; }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const query: DocumentNode = gql` query somethingelse { allPeople(first: 1) { people { name } } } `; const data = { allPeople: { people: [{ name: 'Luke Skywalker' }] } }; const dataTwo = { allPeople: { people: [{ name: '...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => { observable.refetch().then(() => { reject('Expected error value on first refetch.'); }, noop); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => { reject('Expected error value on first refetch.'); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => { observable.refetch().catch(() => { reject('Expected good data on second refetch.'); }); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => { reject('Expected good data on second refetch.'); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const query = gql` query { posts { foo __typename } } `; const errors: GraphQLError[] = [ new GraphQLError('Cannot query field "foo" on type "Post".') ]; const link = mockSingleLink({ request: { query }, resu...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
err => { expect(err.message).toBe( 'Cannot query field "foo" on type "Post".', ); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const query = gql` query { todos { id name description __typename } } `; const result = { data: { todos: [ { id: '1', name: 'Todo 1', price: 100, ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
({ data }) => { expect(data).toEqual(result.data); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const query = gql` { books(skip: 0, limit: 2) @connection(key: "abc") { name } } `; const transformedQuery = gql` { books(skip: 0, limit: 2) { name __typename } } `; const result = { ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const query = gql` { books(skip: 0, limit: 2) { name } } `; const transformedQuery = gql` { books(skip: 0, limit: 2) { name __typename } } `; const result = { books: [ { ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => "abc"
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const query = gql` { books(skip: 0, limit: 2) @connection(key: "books") { name } } `; const transformedQuery = gql` { books(skip: 0, limit: 2) { name __typename } } `; const result = { ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const query = gql` { books(skip: 0, limit: 2) @connection(key: "abc") { name } } `; const transformedQuery = gql` { books(skip: 0, limit: 2) { name __typename } } `; const result = { ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
actualResult => { expect(actualResult.data).toEqual(result); expect((client.cache as InMemoryCache).extract()).toMatchSnapshot(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const query = gql` query books($order: string) { books(skip: 0, limit: 2, order: $order) @connection(key: "abc", filter: ["order"]) { name } } `; const transformedQuery = gql` query books($order: string) { books(skip: 0, l...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const query = gql` query books($order: string) { books(skip: 0, limit: 2, order: $order) { name } } `; const transformedQuery = gql` query books($order: string) { books(skip: 0, limit: 2, order: $order) { name __...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async (resolve, reject) => { const aVar = makeVar(123); const bVar = makeVar("asdf"); const cache: InMemoryCache = new InMemoryCache({ typePolicies: { Query: { fields: { a() { return aVar(); }, b() { return bVar(); ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
obsQuery => obsQuery.resetLastResults()
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
resolve => setTimeout(resolve, time)
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
async (resolve, reject) => { const aVar = makeVar(123); const bVar = makeVar("asdf"); const aSpy = jest.spyOn(aVar, "forgetCache"); const bSpy = jest.spyOn(bVar, "forgetCache"); const cache: InMemoryCache = new InMemoryCache({ typePolicies: { Query: { fields: { a...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => { const query = gql` query number { myNumber { n } } `; const initialData = { myNumber: { n: 1, }, }; const networkFetch = { myNumber: { n: 2, }, }; itAsync('allows setting default options for watchQuery',...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const link = mockSingleLink({ request: { query }, result: { data: networkFetch }, }).setOnError(reject); const client = new ApolloClient({ link, cache: new InMemoryCache({ addTypename: false }), defaultOptions: { watchQuery: { ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(handleCount, result) => { const resultData = result.data; if (handleCount === 1) { expect(resultData).toEqual(initialData); } else if (handleCount === 2) { expect(resultData).toEqual(networkFetch); resolve(); } }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { let networkCounter = 0; let nextFetchPolicyCallCount = 0; const client = new ApolloClient({ link: new ApolloLink(operation => new Observable(observer => { observer.next({ data: { count: networkCounter++, }, }); ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
operation => new Observable(observer => { observer.next({ data: { count: networkCounter++, }, }); observer.complete(); })
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
observer => { observer.next({ data: { count: networkCounter++, }, }); observer.complete(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
fetchPolicy => { ++nextFetchPolicyCallCount; return "cache-first"; }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(handleCount, result) => { if (handleCount === 1) { expect(nextFetchPolicyCallCount).toBe(1); expect(result.data).toEqual({ count: "initial" }); // Refetching makes a copy of the current options, which // includes options.nextFetchPolicy, so the inner // nextFe...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const errors = [{ message: 'failure', name: 'failure' }]; const link = mockSingleLink({ request: { query }, result: { errors }, }).setOnError(reject); const client = new ApolloClient({ link, cache: new InMemoryCache({ addTypename: false }),...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
result => { expect(result.errors).toEqual(errors); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
(resolve, reject) => { const mutation = gql` mutation upVote($id: ID!) { upvote(id: $id) { success } } `; const data = { upvote: { success: true }, }; const link = mockSingleLink({ request: { query: mutation, variables: { i...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
result => { expect(result.data).toEqual(data); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
result => { expect(result.data).toEqual(data.data); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
next() { throw expectedError; }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
next() { reject(new Error('did not expect next to be called')); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
error() { throw expectedError; }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
next(result) { expect(result.data).toEqual(data); resolve(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
next() { client .mutate({ mutation, updateQueries, update: updateSpy }) .then(() => { expect(queryUpdaterSpy).toBeCalled(); expect(updateSpy).toBeCalled(); sub.unsubscribe(); resolve(); }) .catch(err => { reject...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
error(err) { reject(err); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
error(error) { expect(error.message).toBe('Uh oh!'); resolve(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
next(result: any) { try { switch (count++) { case 0: if (!result.data!.allPeople) { reject('Should have data by this point'); break; } // First result is loaded, run a refetch to get the second result ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
error(error: Error) { expect(count++).toBe(2); expect(error.message).toBe('This is an error!'); subscription.unsubscribe(); const lastError = observable.getLastError(); expect(lastError).toBeInstanceOf(ApolloError); expect(lastError!.networkError).toEqual(error); ...
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
a() { return aVar(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
b() { return bVar(); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
next(result) { results.push(result.data); }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
c(value) { expect(value).toBe("see"); return "saw"; }
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
MethodDeclaration
nextFetchPolicy(fetchPolicy) { expect(++nextFetchPolicyCallCount).toBe(1); expect(this.query).toBe(query); expect(fetchPolicy).toBe("cache-first"); // Usually options.nextFetchPolicy applies only once, but a // nextFetchPolicy function can set this....
AaronSuAu/apollo-client
src/__tests__/client.ts
TypeScript
ArrowFunction
() => { this.props.removeToast({ id: toast.id }); }
onka13/react-native-ts-boilerplate
app/src/ui/components/DynamicControl.tsx
TypeScript
ArrowFunction
finished => { this.shouldUpdate = true; this.setState({ controls: nextProps.dynamic.controls, }); }
onka13/react-native-ts-boilerplate
app/src/ui/components/DynamicControl.tsx
TypeScript
ClassDeclaration
class DynamicControl extends React.Component<Prop, State> { _defaultOptions = {}; shouldUpdate = true; state = { controls: {}, toasts: [], }; constructor(props: any) { super(props); this.state.toasts = this.props.dynamic.toasts || []; } _getControls(controlsState: any) { var arr = []; for (var key i...
onka13/react-native-ts-boilerplate
app/src/ui/components/DynamicControl.tsx
TypeScript
InterfaceDeclaration
interface Prop { dynamic: any; removeToast: any; }
onka13/react-native-ts-boilerplate
app/src/ui/components/DynamicControl.tsx
TypeScript
InterfaceDeclaration
interface State { controls: any; toasts: any; }
onka13/react-native-ts-boilerplate
app/src/ui/components/DynamicControl.tsx
TypeScript
MethodDeclaration
_getControls(controlsState: any) { var arr = []; for (var key in controlsState) { if (!Object.prototype.hasOwnProperty.call(controlsState, key)) continue; var cs = controlsState[key]; if (cs.options.animationX || cs.options.animationY) { arr.push( <SlideUpDownViewControl ref={key} key={key} style...
onka13/react-native-ts-boilerplate
app/src/ui/components/DynamicControl.tsx
TypeScript
ClassDeclaration
export default class CompleteActivityRequestRepository implements ICompleteActivityRequestRepository { public async findAllFromGame( gameId: string, ): Promise<ICompleteActivityRequest[]> { return CompleteActivityRequest.find({ game: gameId }) .populate('activity') .populate({ path: '...
raulrozza/Gametask_API
src/modules/players/infra/mongoose/repositories/CompleteActivityRequestRepository.ts
TypeScript
MethodDeclaration
public async findAllFromGame( gameId: string, ): Promise<ICompleteActivityRequest[]> { return CompleteActivityRequest.find({ game: gameId }) .populate('activity') .populate({ path: 'requester', populate: { path: 'user', }, }) .sort({ requestDate: -1 }...
raulrozza/Gametask_API
src/modules/players/infra/mongoose/repositories/CompleteActivityRequestRepository.ts
TypeScript
MethodDeclaration
public async findOne( id: string, ): Promise<ICompleteActivityRequest | undefined> { if (!isValidObjectId(id)) throw new RequestError('Id is invalid!', errorCodes.INVALID_ID); const request = await CompleteActivityRequest.findById(id) .populate('activity') .populate({ path: 're...
raulrozza/Gametask_API
src/modules/players/infra/mongoose/repositories/CompleteActivityRequestRepository.ts
TypeScript
MethodDeclaration
public async create( { requester, activity, requestDate, completionDate, information, game, }: CreateCompleteActivityRequestAdapter, session?: ClientSession, ): Promise<ICompleteActivityRequest> { const [result] = await CompleteActivityRequest.create( [ ...
raulrozza/Gametask_API
src/modules/players/infra/mongoose/repositories/CompleteActivityRequestRepository.ts
TypeScript
MethodDeclaration
public async delete( id: string, gameId: string, session?: ClientSession, ): Promise<void> { if (!isValidObjectId(id)) throw new RequestError('Id is invalid!', errorCodes.INVALID_ID); await CompleteActivityRequest.deleteOne( { _id: id, game: gameId }, { session }, ); }
raulrozza/Gametask_API
src/modules/players/infra/mongoose/repositories/CompleteActivityRequestRepository.ts
TypeScript
FunctionDeclaration
/** * Install all exarcheia-element components into Vue. * Please do not invoke this method directly. * Call `Vue.use(ElementUI)` to install. */ export function install (vue: typeof Vue, options: InstallationOptions): void
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
// TS cannot merge imported class with namespace, so declare subclasses instead /** Alert Component */ export class Alert extends ElAlert {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Aside Component */ export class Aside extends ElAside {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Autocomplete Component */ export class Autocomplete extends ElAutocomplete {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Bagde Component */ export class Badge extends ElBadge {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Breadcrumb Component */ export class Breadcrumb extends ElBreadcrumb {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Breadcrumb Item Component */ export class BreadcrumbItem extends ElBreadcrumbItem {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Button Component */ export class Button extends ElButton {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Button Group Component */ export class ButtonGroup extends ElButtonGroup {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Card Component */ export class Card extends ElCard {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Cascader Component */ export class Cascader extends ElCascader {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Carousel Component */ export class Carousel extends ElCarousel {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Carousel Item Component */ export class CarouselItem extends ElCarouselItem {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Checkbox Component */ export class Checkbox extends ElCheckbox {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Checkbox Button Component */ export class CheckboxButton extends ElCheckboxButton {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript
ClassDeclaration
/** Checkbox Group Component */ export class CheckboxGroup extends ElCheckboxGroup {}
exarcheia/element
types/exarcheia-element.d.ts
TypeScript