From 2ab5b3991528d7290a99b8935bdc7a0d76355bad Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Sun, 18 Jun 2017 18:29:01 -0400 Subject: [PATCH] [jquery] Add tests for data-related methods on JQuery. --- types/jquery/jquery-tests.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 03c8d18360..f55232e43e 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -706,6 +706,42 @@ function JQuery() { } } + function data() { + function data() { + // $ExpectType any + $('p').data('myData', undefined); + + // $ExpectType JQuery + $('p').data('myData', {}); + + // $ExpectType JQuery + $('p').data({ + myData1: {}, + myData2: false + }); + + // $ExpectType any + $('p').data('myData'); + + // $ExpectType PlainObject + $('p').data(); + } + + function removeData() { + // $ExpectType JQuery + $('p').removeData('myData'); + + // $ExpectType JQuery + $('p').removeData([ + 'myData1', + 'myData2' + ]); + + // $ExpectType JQuery + $('p').removeData(); + } + } + function on() { function false_handler_shorthand() { $().on('events', false);