2018-01-21 01:45:17 +01:00
|
|
|
// Copyright 2018 Google Inc. Use of this source code is governed by an
|
|
|
|
// MIT-style license that can be found in the LICENSE file or at
|
|
|
|
// https://opensource.org/licenses/MIT.
|
|
|
|
|
|
|
|
import 'dart:js_util';
|
|
|
|
|
|
|
|
import 'package:js/js.dart';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
2020-04-22 01:03:58 +02:00
|
|
|
import 'package:sass/src/node/utils.dart';
|
|
|
|
|
2018-01-21 01:45:17 +01:00
|
|
|
import '../api.dart';
|
|
|
|
import '../utils.dart';
|
|
|
|
|
|
|
|
/// Parses [source] by way of a function call.
|
|
|
|
T parseValue<T>(String source) {
|
|
|
|
T value;
|
2018-11-16 00:16:24 +01:00
|
|
|
renderSync(RenderOptions(
|
2018-01-21 01:45:17 +01:00
|
|
|
data: "a {b: foo(($source))}",
|
|
|
|
functions: jsify({
|
|
|
|
r"foo($value)": allowInterop(expectAsync1((T value_) {
|
|
|
|
value = value_;
|
|
|
|
return sass.types.Null.NULL;
|
|
|
|
}))
|
|
|
|
})));
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A matcher that matches values that are JS `instanceof` [type].
|
2020-04-22 01:03:58 +02:00
|
|
|
Matcher isJSInstanceOf(Object type) => predicate(
|
|
|
|
(value) => jsInstanceOf(value, type), "to be an instance of $type");
|